package com.kkd.kkdapp.http.parser;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.kkd.kkdapp.http.entity.Verification;

public class VerificationParser {

	private JSONObject result;

	public VerificationParser(String response) throws JSONException {

		result = new JSONObject(response);

	}

	public int getCoder() throws JSONException {
		int code = result.getInt("code");

		return code;

	}

	public String getMessage() throws JSONException {
		String message = result.getString("desc");

		return message;

	}

	public Verification getData() throws JSONException {
		JSONObject data = result.getJSONObject("data");
		Gson gson = new Gson();
		Verification verification = gson.fromJson(data.toString(),
				new TypeToken<Verification>() {
				}.getType());
		return verification;
	}

}
